package com.yx.louti.globalException.model;

import com.yx.louti.globalException.enums.HttpResultCode;
import jtool.JThrow;

/**
 * 异常结果包装类
 *
 */
public class HttpErrorResult {

    private Integer code;

    private String message;

    private String exception;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    public static HttpErrorResult fail(HttpResultCode HttpResultCode, Throwable e, String message) {
        HttpErrorResult errorResult = HttpErrorResult.fail(HttpResultCode, e);
        errorResult.setMessage(message);
        errorResult.setException(JThrow.toString(e));
        return errorResult;
    }

    public static HttpErrorResult fail(HttpResultCode HttpResultCode, Throwable e) {
        HttpErrorResult errorResult = new HttpErrorResult();
        errorResult.setCode(HttpResultCode.code());
        errorResult.setMessage(HttpResultCode.message());
        errorResult.setException(JThrow.toString(e));
        return errorResult;
    }

    public static HttpErrorResult fail(Integer code, String message) {
        HttpErrorResult errorResult = new HttpErrorResult();
        errorResult.setCode(code);
        errorResult.setMessage(message);
        return errorResult;
    }
}
